package com.nbsaas.boot.product.rest.resource;

import com.nbsaas.boot.product.api.apis.ProductVisitApi;
import com.nbsaas.boot.product.data.entity.ProductVisit;
import com.nbsaas.boot.product.api.domain.request.ProductVisitRequest;
import com.nbsaas.boot.product.api.domain.response.ProductVisitResponse;
import com.nbsaas.boot.product.api.domain.simple.ProductVisitSimple;
import com.nbsaas.boot.product.rest.convert.ProductVisitSimpleConvert;
import com.nbsaas.boot.product.rest.convert.ProductVisitEntityConvert;
import com.nbsaas.boot.product.rest.convert.ProductVisitResponseConvert;
import com.nbsaas.boot.product.data.repository.ProductVisitRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   商品浏览记录-业务接口实现
*/
@Transactional
@Service
public class ProductVisitResource extends BaseResource<ProductVisit,ProductVisitResponse, ProductVisitSimple, ProductVisitRequest>  implements ProductVisitApi {

    @Resource
    private ProductVisitRepository productVisitRepository;

    @Override
    public JpaRepositoryImplementation<ProductVisit, Serializable> getJpaRepository() {
        return productVisitRepository;
    }

    @Override
    public Function<ProductVisit, ProductVisitSimple> getConvertSimple() {
        return new ProductVisitSimpleConvert();
    }

    @Override
    public Function<ProductVisitRequest, ProductVisit> getConvertForm() {
        return new ProductVisitEntityConvert();
    }

    @Override
    public Function<ProductVisit, ProductVisitResponse> getConvertResponse() {
        return new ProductVisitResponseConvert();
    }




}


